﻿
Imports System.IO
Imports xmlctrl
Imports xhtmlctrl
Imports webctrl

Public Class tworails
    Inherits container

    Public Class datasource
        Public leftrailWidthPercent As Byte
        Public rightrailWidthPercent As Byte
        Public margin As Byte

        Public Sub New(ByVal leftrailWidthPercent As Byte, ByVal rightrailWidthPercent As Byte, ByVal margin As Byte)
            Me.leftrailWidthPercent = leftrailWidthPercent
            Me.rightrailWidthPercent = rightrailWidthPercent
            Me.margin = margin
        End Sub
    End Class

    Public Const leftrailClass As String = "lr"
    Public Const rightrailClass As String = "rr"

    Private _leftrail As div = Nothing
    Private _rightrail As div = Nothing

    Public Function leftrail() As div
        assert(Not _leftrail Is Nothing, "have not created valid _leftrail.")
        Return _leftrail
    End Function

    Public Function rightrail() As div
        assert(Not _rightrail Is Nothing, "have not created valid _rightrail.")
        Return _rightrail
    End Function

    Public Sub New(ByVal ds As datasource, Optional ByVal buff As Stream = Nothing)
        Me.New(buff)
        setData(ds)
    End Sub

    Public Sub New(Optional ByVal buff As Stream = Nothing)
        MyBase.New(buff)
    End Sub

    Public Sub setData(ByVal ds As datasource)
        assert(Not ds Is Nothing, "do not have valid datasource.")
        _leftrail = New div()
        addchild(leftrail())
        leftrail().class = leftrailClass
        leftrail().style = "float:left;width:" + Convert.ToString(ds.leftrailWidthPercent) + "%;" + _
                           "margin-right:" + Convert.ToString(ds.margin) + "%;"
        _rightrail = New div()
        addchild(rightrail())
        rightrail().class = rightrailClass
        rightrail().style = "float:left;width:" + Convert.ToString(ds.rightrailWidthPercent) + "%;"
    End Sub
End Class
